package cn.elead.it.sso.config;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import cn.elead.it.sso.core.store.SsoLoginStore;
import cn.elead.it.sso.core.util.JedisUtil;
import cn.elead.it.sso.properties.SsoProperties;

/**
 * redis配置
 * 
 * @author luopeng
 *
 */
@Configuration
public class RedisConfig implements InitializingBean, DisposableBean {

	@Autowired
	private SsoProperties ssoProperties;

	@Override
	public void afterPropertiesSet() throws Exception {
		SsoLoginStore.setRedisExpireMinite(ssoProperties.getRedis().getExpireMinite());
		JedisUtil.init(ssoProperties.getRedis().getAddress());
	}

	@Override
	public void destroy() throws Exception {
		JedisUtil.close();
	}

}
